package com.rwdesign.springboot.Waimai.service.Impl;

import com.rwdesign.springboot.Waimai.dao.GoodsMapper;
import com.rwdesign.springboot.Waimai.dao.ShopMapper;
import com.rwdesign.springboot.Waimai.entity.Goods;
import com.rwdesign.springboot.Waimai.entity.Shop;
import com.rwdesign.springboot.Waimai.service.GoodsService;
import com.rwdesign.springboot.Waimai.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author rystart
 * @create 2022-01-29 12:39
 */
@Service
@Slf4j
public class GoodsServiceImpl implements GoodsService {

    @Resource
    private GoodsMapper goodsMapper;


    @Override
    public List<String> selectAllGoodsTypes(Integer shopId) {
        return goodsMapper.selectAllGoodsTypes(shopId);
    }

    @Override
    public Goods selectGoodsById(Integer goodsId) {
        return goodsMapper.selectGoodsById(goodsId);
    }

    @Override
    public List<Goods> selectAllGoods(String goodsType, Integer shopId) {
        return goodsMapper.selectAllGoods(goodsType, shopId);
    }

    /**
     * 新增商品
     *
     * @param goods
     * @return
     */
    @Override
    public Integer addGoods(Goods goods) {
        return goodsMapper.addGoods(goods);
    }

    @Override
    public Integer deleteGoodsById(Integer goodsId) {
        return goodsMapper.deleteGoodsById(goodsId);
    }

    /**
     * 编辑商品
     *
     * @param goods
     * @return
     */
    @Override
    public Integer updataGoods(Goods goods) {
        return goodsMapper.updataGoods(goods);
    }


    /**
     * @return
     * @Author chendanping
     * @Description //TODO 查询商品所属的shopId
     * @Date 20:41 2022/3/8
     * @Param
     **/
    @Override
    public Integer selectShopIdByGoodsId(Integer goodsId) {
        return goodsMapper.selectShopIdByGoodsId(goodsId);
    }


}
